package com.wudl.core;


import com.wudl.bean.WaterSensor;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


/**
 * @ClassName : SourceConllection
 * @Description : 读取集合
 * @Author :wudl
 * @Date: 2020-10-22 00:20
 */

public class SourceConllection {
    public static void main(String[] args) throws Exception {

        // 获取上下文的环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        List<WaterSensor> ts =  Arrays.asList(
                        new WaterSensor("sensor_1", 15321312412L, 41),
                        new WaterSensor("sensor_2", 15321763412L, 47),
                        new WaterSensor("sensor_3", 15369732412L, 49)
        );
        DataStreamSource<WaterSensor> dataStream = env.fromCollection(ts );
        dataStream.print();
        env.execute();
    }
}
